package cn.com.doone.common.uc.web.controller;

import java.util.Collection;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.session.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import cn.com.doone.common.uc.domain.oauth.Constants;
import cn.com.doone.common.uc.oauth.shiro.RedisSessionDao;

@RequiresPermissions("session:*")  
@Controller  
@RequestMapping("/sessions") 
public class SessionController {
	
	/*@Autowired  
    private RedisSessionDao redisShiroSessionDAO;
	
    @RequestMapping()  
    public String list(Model model) {  
        Collection<Session> sessions =  redisShiroSessionDAO.getActiveSessions();  
        model.addAttribute("sessions", sessions);  
        model.addAttribute("sesessionCount", sessions.size());  
        return "sessions/list";  
    }
    
    @RequestMapping("/{sessionId}/forceLogout")  
    public String forceLogout(@PathVariable("sessionId") String sessionId,   
        RedirectAttributes redirectAttributes) {  
        try {  
            Session session = redisShiroSessionDAO.readSession(sessionId);  
            if(session != null) {  
                session.setAttribute(Constants.SESSION_FORCE_LOGOUT_KEY, Boolean.TRUE);  
            }  
        } catch (Exception e) {ignore}  
        redirectAttributes.addFlashAttribute("msg", "强制退出成功！");  
        return "redirect:/sessions";  
    }*/

}
